<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class AreaCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app:area';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        foreach (DB::table('area-code')->get(['id', 'code']) as $v) {
            //dd(str_pad($v->code, 6, '0'));
            DB::table('area')->where('id', $v->id)->update([
                'code' => str_pad($v->code, 6, 0),
            ]);
        }
    }
}

